﻿using Simple.ISysRepository;
using Simple.Tools;
using SimpleSaas.Common.DataBase;
using SimpleSaas.Entity;
using SimpleSaas.Entity.View;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simple.SysRepository
/// <summary>
/// 版 本 钢易智企2.0 V 2.0.0 钢易智企2.0
/// Copyright (c) 2023 杭州钢易科技有限公司
/// 创建人：曾东明
/// 日 期：2024
/// 描 述：
/// </summary>
{
	public class SysMenuRepository : WholeRepository<SysMenuEntity, long>, ISysMenuRepository
	{
		public SysMenuRepository() { }

		/// <summary>
		/// 
		/// </summary>
		/// <param name="matchCondition"></param>
		/// <returns></returns>
		public ISugarQueryable<SysMenuView> Query(Action<ISugarQueryable<SysMenuEntity>> matchCondition)
		{
			SimpleCheck.IsNullThrowException(matchCondition);
			var query=dbClient.Queryable<SysMenuEntity>();
			matchCondition.Invoke(query);

			return query.Select(m => new SysMenuView 
			{
				Id=m.Id.ToString(),
				Sort=m.Sort,
				AppId=m.AppId,
				CreationTime=m.CreationTime,
				Icon=m.Icon,
				MenuName=m.MenuName,
				MenuType=m.MenuType,
				ParentId=m.ParentId,
				Path=m.Path,
			});
		}

	}
}
